home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / lang / Python152_Src.lha / Python152_Source / Amiga / usleep.c < prev    next >
C/C++ Source or Header  |  1998-12-25  |  1KB  |  66 lines

  1. RCS_ID_C="$Id: usleep.c,v 4.1 1994/09/29 23:09:02 jraja Exp $"
  2. /*
  3.  *      usleep.c - suspend process for the specified time
  4.  *
  5.  *      Copyright © 1994 AmiTCP/IP Group, 
  6.  *                       Network Solutions Development Inc.
  7.  *                       All rights reserved.
  8.  */
  9.  
  10. #include <sys/param.h>
  11. #ifdef AMITCP
  12. #include <unistd.h>
  13. #endif
  14. #ifdef INET225
  15. #include <proto/socket.h>
  16. #endif
  17. #include <sys/time.h>
  18. #include <sys/socket.h>
  19.  
  20. /****** net.lib/usleep *********************************************
  21.  
  22.     NAME
  23.     usleep - suspend process execution for the specified time
  24.  
  25.     SYNOPSIS
  26.     void usleep(unsigned int microseconds);
  27.  
  28.     FUNCTION
  29.         Process execution is suspended for number of microseconds
  30.         specified in 'microseconds'. The sleep will be aborted if any
  31.         of the break signals specified for the process is received
  32.         (only CTRL-C by default).
  33.  
  34.     PORTABILITY
  35.     UNIX
  36.  
  37.     INPUTS
  38.     'microseconds' - number of microseconds to sleep.
  39.  
  40.     RESULT
  41.         Does not return a value.
  42.  
  43.     NOTES
  44.         The sleep is implemented as a single select() call with all other
  45.         than time out argument as NULL.
  46.  
  47.     SEE ALSO
  48.     bsdsocket.library/select()
  49.  
  50. *****************************************************************************
  51. *
  52. */
  53.  
  54. void usleep(unsigned int usecs)
  55. {
  56.   struct timeval tv;
  57.  
  58.   tv.tv_sec = 0;
  59.   while (usecs >= 1000000) {
  60.     usecs -= 1000000;
  61.     tv.tv_sec++;
  62.   }    
  63.   tv.tv_usec = usecs;
  64.   select(0, 0, 0, 0, &tv);
  65. }
  66.